<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>会员管理</title>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/style.css" />
<script src="__PUBLIC__/js/jquery.js" type="text/javascript"></script>
<script src="__PUBLIC__/artDialog/jquery.artDialog.js?skin=default" type="text/javascript"></script>
<script src="__PUBLIC__/artDialog/plugins/iframeTools.js" type="text/javascript"></script>
<script src="__PUBLIC__/js/ajax.js" type="text/javascript"></script>
<script src="__PUBLIC__/DatePicker/WdatePicker.js" type="text/javascript"></script>
</head>
<body>
<div id="main">
    <form id="login-form" action="__URL__/edit" method="post">
        <input type="hidden" value="post" name="action" />
        <input type="hidden" value="{$info['id']}" name="fid" />
        <table width="100%" class="table_form">
            <tr><th width="60">用户</th><td><input id="username" type="text" name="username"  class="input-text" size="40" value="{$info['username']}" /><span class="hot">*</span></td></tr>
            <tr><th>信箱</th><td><input id="email" type="text" name="email"  class="input-text" size="40" value="{$info['email']}" /><span class="hot">*</span></td></tr>
            <tr><th>手机</th><td><input id="iphone" type="text" name="iphone"  class="input-text" size="15" value="{$info['iphone']}" /><span class="hot">*</span></td></tr>
            <tr><th>密码</th><td><input id="password" type="password" name="password" class="input-text" size="20" value="" /></td></tr>
            <tr><th>姓名</th><td><input id="name" type="text" name="name"  class="input-text" size="10" value="{$info['name']}" /><span class="hot">*</span></td></tr>
            <tr><th>性别</th><td><input type="radio" value="男" name="sex" checked ="checked" /> 男&nbsp;&nbsp;<input type="radio" value="1" name="sex"<?php if($info['sex'] == '女') echo " checked =\" checked\""?> /> 女</td></tr>
            <tr><th>生日</th><td><input onClick="WdatePicker()" type="text" name="birthday"  class="input-text input-date" size="20" value="{$info['birthday']}" readonly="readonly"/></td></tr>
            <tr><th>QQ</th><td><input type="text" name="qq"  class="input-text" size="15" value="{$info['qq']}" /></td></tr>
            <tr><th>地址</th><td><input type="text" name="address"  class="input-text" size="50" value="{$info['address']}" /></td></tr>
            <tr><th>消费积分</th><td><input id="vip" type="text" name="vip"  class="input-text" size="10" value="{$info['vip']}" /><span class="hot">*</span> 可用作消费的积分</td></tr>
            <tr><th>等级积分</th><td><input id="allvip" type="text" name="allvip"  class="input-text" size="10" value="{$info['allvip']}" /><span class="hot">*</span> 等级判断!没特殊要求不要修改</td></tr> 
            <tr><th>备注</th><td><textarea name="about" style="width: 400px;height: 60px">{$info['about']}</textarea></td></tr>
            <tr><th>锁定</th><td><input type="radio" value="2" name="lock" checked ="checked" /> 否&nbsp;&nbsp;<input type="radio" value="1" name="lock"<?php if($info['lock'] == 1) echo " checked =\" checked\""?> /> 是</td></tr>
        </table>
    </form>
</div>
    <script type="text/javascript">
        $(function () {
            var parent = art.dialog.parent,	// 父页面window对象
            api = art.dialog.open.api,//art.dialog.open扩展方法
            $ = function (id) {return document.getElementById(id)},
            form     = $('login-form'),
            username = $('username'),
            email    = $('email'),
            iphone   = $('iphone'),
            {if !$info['id']}
            password = $('password'),
            {/if}
            name     = $('name')
            vip      = $('vip'),
            allvip   = $('allvip');
            if (!api) return;
            api.title('删除/编辑')// 操作对话框
            .button({ // 自定义按钮
                name: '提交',
                callback: function () {
                    if (check(username)&&isemail(email)&&istel(iphone){if !$info['id']}&&check(password){/if}&&check(name)&&isnum(vip)&&isnum(allvip)) form.submit();
                    return false;
                },focus: true
            },{name: '取消'});
            // 表单验证
            var check = function (input) {
                if (input.value === '') {
                    inputError(input);
                    input.focus();
                    return false;
                } else {
                    return true;
                };
            };
            // 是否数字
            var isnum = function (input) {
                var strP=/^\d+$/;
                if(!strP.test(input.value)){
                    inputError(input);
                    input.focus();
                    return false;
                }else {
                    return true;
                };
            };
            // 是否手机号
            var istel = function (input) {
                var strP=/^(1[3458])\d{9}$/;
                if(!strP.test(input.value)){
                    inputError(input);
                    input.focus();
                    return false;
                }else {
                    return true;
                };
            };  
            // 是否信箱
            var isemail = function (input) {
                var strP=/^[a-z]([a-z0-9]*[-_]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[\.][a-z]{2,3}([\.][a-z]{2})?$/;
                if(!strP.test(input.value)){
                    inputError(input);
                    input.focus();
                    return false;
                }else {
                    return true;
                };
            };         
            // 输入错误提示
            var inputError = function (input){
                clearTimeout(inputError.timer);
                var num = 0;
                var fn = function () {
                    inputError.timer = setTimeout(function () {
                        input.className = input.className === '' ? 'login-form-error' : '';
                        if (num === 5) {
                            input.className === '';
                        } else {
                            fn(num ++);
                        };
                    }, 150);
                };
                fn();
            };
            window.onload = function () {setTimeout(function () {username.focus()}, 240);};
        })();
    </script>
</body>
</html>